{php $top_name=MODULE_NAME;}{template "header.html"}


<div class="page-container">
    <div class="page-content-wrapper">
        <div class="page-content bg-b">
            <div class="container  pd-0">

                <div class="news-search">

                    <div class="input-group news-search-param-keyword">
                        <input type="text" placeholder="输入关键字搜索" onkeypress="if(event.keyCode==13) {searchByClass();return false;}" name='keyword' value='{$keyword}' id='dr_search_keyword' class="form-control">
                        <span class="input-group-btn"> <button class="btn default"  onclick="searchByClass()" type="button"> <i class="fa fa-search"></i> </button> </span>
                        <script type="text/javascript">
                            function searchByClass(){
                                var url="{dr_search_url($params, 'keyword', 'phpkaiyuancms')}";
                                var value=$("#dr_search_keyword").val();
                                if (value) {
                                    location.href=url.replace('phpkaiyuancms', value);
                                } else {
                                    dr_tips("输入关键字");
                                }
                            }
                        </script>
                    </div>

                </div>


                <div class="news-search-params">
                    <div class="search-params">

                        <div class="btn-group ">
                            <button class="btn search dropdown-toggle" data-toggle="dropdown"> 排序
                                <i class="fa fa-angle-down"></i>
                            </button>
                            <ul class="dropdown-menu" role="menu">
                                <li class="{if !$get.order || $get.order=='updatetime'}active{/if}">
                                    <a href="{dr_search_url($params, 'order', null)}"> 默认排序 </a>
                                </li>
                                <li role="presentation" class="divider"> </li>
                                <li class="{if $get.order=='hits'}active{/if}">
                                    <a  href="{dr_search_url($params, 'order', 'hits')}"> 人气降序 <i class="fa fa-long-arrow-down"></i> </a>
                                </li>
                                <li class="{if $get.order=='hits_asc'}active{/if}">
                                    <a  href="{dr_search_url($params, 'order', 'hits_asc')}"> 人气升序 <i class="fa fa-long-arrow-up"></i> </a>
                                </li>
                                <li role="presentation" class="divider"> </li>
                                <li class="{if $get.order=='comments'}active{/if}">
                                    <a  href="{dr_search_url($params, 'order', 'comments')}"> 评论降序 <i class="fa fa-long-arrow-down"></i> </a>
                                </li>
                                <li class="{if $get.order=='comments_asc'}active{/if}">
                                    <a  href="{dr_search_url($params, 'order', 'comments_asc')}"> 评论升序 <i class="fa fa-long-arrow-up"></i> </a>
                                </li>

                            </ul>
                        </div>



                    </div>
                </div>

                <ul id="innerrow" class="list_normal list_bbs">
                    {template "search_data.html"}
                </ul>
                <div class="clear"></div>

                <div class="innerrow_ajax_loading">
                    <img src="{HOME_THEME_PATH}mobile/img/ajax-loading.gif">
                </div>

                <script>
                    var dr_page = 1;
                    var dr_rkcb = 1;
                    $(window).on("scroll", function() {
                        if (toBottom()) {
                            $('.innerrow_ajax_loading').show();
                            dr_page++; // 加载下一页的意思
                            var search_url = '{dr_search_url($params, NULL, NULL, MOD_DIR, 1)}&ajax_page=search_data.html&page='+dr_page;

                            $.get(search_url, function (html) {
                                if (html.indexOf("<li>") == -1) {
                                    dr_rkcb = 0;
                                } else {
                                    $('#innerrow').append(html); // 将返回的内容追加到内容区域
                                    dr_rkcb = 1;
                                }
                                $('.innerrow_ajax_loading').hide();
                            });
                        }
                    });
                    function toBottom() {
                        if (dr_rkcb == 0) {
                            return false;
                        }
                        var scrollTop = $(window).scrollTop();
                        var clientHeight = $(window).height();
                        var offsetTop = $("#innerrow li:last-child").offset().top;
                        console.log(scrollTop + "..." + clientHeight + "..." + offsetTop);
                        if (scrollTop + clientHeight > offsetTop) {
                            dr_rkcb = 0;
                            return true;
                        } else {
                            return false;
                        }
                    }
                </script>
            </div>
        </div>
    </div>
</div>
{template "footer.html", "/"}